package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.CldOvertimeDetails;
import com.cleaningcloud.cld.domain.dto.CldOvertimeDto;
import com.cleaningcloud.cld.domain.vo.CldOvertimeDetailsVo;
import com.cleaningcloud.cld.domain.vo.CldOvertimeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldOvertime;
import com.cleaningcloud.cld.service.ICldOvertimeService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 加班管理Controller
 * 
 * @author cleaningcloud
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/overtime")
public class CldOvertimeController extends BaseController
{
    @Autowired
    private ICldOvertimeService cldOvertimeService;

    /**
     * 查询加班管理列表
     */
    @RequiresPermissions("cld:overtime:list")
    @GetMapping("/list")
    public TableDataInfo list(CldOvertimeDto cldOvertime)
    {
        startPage();
        List<CldOvertimeVo> list = cldOvertimeService.selectCldOvertimeList(cldOvertime);
        return getDataTable(list);
    }


    /**
     * 获取加班管理详细信息
     */
    @RequiresPermissions("cld:overtime:query")
    @GetMapping(value = "/loadDetails")
    public AjaxResult getInfo(CldOvertimeDetailsVo detailsVo)
    {
        return success(cldOvertimeService.selectCldOvertimeByOvertimeId(detailsVo));
    }


    /**
     * 加班统计
     */
    @GetMapping(value = "/selectOvertimeAnalyze")
    public AjaxResult selectOvertimeAnalyze(CldOvertimeDto cldOvertime)
    {
        return success(cldOvertimeService.selectOvertimeAnalyze(cldOvertime));
    }

    /**
     * 新增加班管理
     */
    @RequiresPermissions("cld:overtime:add")
    @Log(title = "新增加班管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldOvertimeDto cldOvertime)
    {
        return toAjax(cldOvertimeService.insertCldOvertime(cldOvertime));
    }

    /**
     * 修改加班管理
     */
    @RequiresPermissions("cld:overtime:edit")
    @Log(title = "修改加班管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldOvertimeDto cldOvertime)
    {
        return toAjax(cldOvertimeService.updateCldOvertime(cldOvertime));
    }


    /**
     * 审核加班管理
     */
    @RequiresPermissions("cld:overtime:audit")
    @Log(title = "审核加班管理", businessType = BusinessType.UPDATE)
    @PutMapping("/audit")
    public AjaxResult audit(@RequestBody CldOvertimeDetails cldOvertimeDetails)
    {
        return toAjax(cldOvertimeService.auditCldOvertime(cldOvertimeDetails));
    }

    /**
     * 删除加班管理
     */
    @RequiresPermissions("cld:overtime:remove")
    @Log(title = "删除加班管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{overtimeIds}")
    public AjaxResult remove(@PathVariable Long[] overtimeIds)
    {
        return toAjax(cldOvertimeService.deleteCldOvertimeByOvertimeIds(overtimeIds));
    }
}
